<template>
	<view class="purchase-list">
		<scroll-view class="purchase-body" scroll-y="true" @scrolltolower="scrolltolower" @scrolltoupper="scrolltoupper"
			show-scrollbar="false">
			<view class="" v-for="item in list_p" style="margin-top: 10px;">
				<p class="fonts12 gray fontz " style="margin-bottom: 10px;text-align: center;">{{item.createTime}}</p>
				<view class="" @click="detail(item.recruitmentPositionVo)">
					<Inventory :data="item.recruitmentPositionVo" />
				</view>
			</view>
			<view class="" v-if="list_p.length==0">
				<Kong />
			</view>
			<view class="">
				<p class="more" v-if="onMore">没有更多了~</p>
				<p class="more" v-if="loading">加载中...</p>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		collection
	} from "@/api/my.js"
	import Inventory from "../../components/Inventory.vue"
	import Kong from "../../components/Kong.vue"
	export default {
		components: {
			Kong,
			Inventory
		},
		data() {
			return {
				onMore: false,
				loading: false,
				totalBool: true,
				list_p: [],
				form_p: {
					pageNum: 1,
					pageSize: 10,
				},
			};
		},
		onShow() {
			this.form_p.pageNum = 1
			this.getlistApi(this.form_p)
		},
		onPullDownRefresh() {
			this.form_p.pageNum = 1
			this.getlistApi(this.form_p)
		},
		methods: {
			detail(item) {
				uni.navigateTo({
					url: "/pages/index/position/position?data=" + JSON.stringify(item)
				})
			},
			getlistApi(params) { //已投递
				this.loading = true
				collection(params).then((res) => {
					this.loading = false
					// this.HeadersData[0].number = res.total
					if (this.form_p.pageNum == 1) {
						this.list_p = res.rows
					} else {
						this.list_p = [...this.list_p, ...res.rows]
					}
					console.log(this.list_p.length, res.total,this.list_p);
					if (this.list_p.length == res.total) {
						this.onMore = true
						this.totalBool = false
						setTimeout(() => {
							this.onMore = false
						}, 2000)
					} else {
						this.totalBool = true
					}
					uni.stopPullDownRefresh()
				})
			},
			scrolltolower(event) {
				if (!this.totalBool) {
					this.onMore = true
					this.totalBool = false
					setTimeout(() => {
						this.onMore = false
					}, 2000)
					return
				}
				this.form_p.pageNum++;
				this.getlistApi(this.form_p)
			
			},
			
			scroll(e) {
				// 重新设置pulldown
				this.setPullDown(e.detail.scrollTop < 10)
			},
			
			scrolltoupper() {
			
			},
		}
	}
</script>

<style lang="scss" scoped>
	.more {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 30px;
		width: 100%;
		font-size: 14px;
		color: #3D3D3D;
	}

	.purchase-list {
		background-color: #f5f5f5;
		height: calc(100vh - 44px);
		overflow: hidden;
		padding: 0 12px;
		.purchase-body {
			height: calc(100vh - 44px);
			overflow-y: auto;

			&::-webkit-scrollbar {
				display: none;
				/*隐藏滚动轴*/
			}
		}
	}
</style>
